
__author__="Action Farsi"
__date__ ="$25-gen-2009 20.25.08$"

import random

def attack(attacker, defender, ability, item):
    att_s = [ s*a for s,a in zip(attacker.stats, ability.att_skill)]
    def_s = [ s*a for s,a in zip(defender.stats, ability.def_skill)]
    res = is_hit(att_s,def_s)
    if res > 0:
        dam = res
        if item != None:
            dam = dam + item.damage
        defender.get_hit(attacker,dam)
        return True
    return False

    
def is_hit(attacker,defender):
    """Given the final stats
    Calculates hit results and normalize to
    
    0 - Nothing
    1 - Hit
    2 - Critical
    """
    ### TODO gauge more interesting
    if sum(attacker) > sum(defender) + random.randint(-4,4):
        return 1
    else:
        return 0
    
def hit(eff,target):
    pass

if __name__ == "__main__":
    print "Hello";